package com.zy.yun.core.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

/**
 * @Author: 王彦委
 * @Description: 资源服务, 对资源进行token认证
 * @Date: 14:38 2019/11/6 0006
 */
@Configuration
@EnableResourceServer
public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {

    @Override
    public void configure(HttpSecurity http) throws Exception {

        // 对 api/order 请求进行拦截
        http.authorizeRequests()
                .antMatchers("oauth/check_token","/oauth/token","oauth/authorize","/login","/quit")
                .permitAll()
                .antMatchers("/**")
                .authenticated()
                .and()
                .httpBasic();
    }

}